package org.overmind.ieat.server.entity;

import javax.persistence.*;
import java.util.Arrays;

/**
 * Created by Overmind on 14.02.2015.
 */
@Entity
@Table(name = "products", schema = "", catalog = "ieat")
public class ProductsEntity {
    private int foodId;
    private String name;
    private byte[] foto;

    @Id
    @Column(name = "food_id")
    public int getFoodId() {
        return foodId;
    }

    public void setFoodId(int foodId) {
        this.foodId = foodId;
    }

    @Basic
    @Column(name = "name")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Basic
    @Column(name = "foto")
    public byte[] getFoto() {
        return foto;
    }

    public void setFoto(byte[] foto) {
        this.foto = foto;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        ProductsEntity that = (ProductsEntity) o;

        if (foodId != that.foodId) return false;
        if (!Arrays.equals(foto, that.foto)) return false;
        if (name != null ? !name.equals(that.name) : that.name != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = foodId;
        result = 31 * result + (name != null ? name.hashCode() : 0);
        result = 31 * result + (foto != null ? Arrays.hashCode(foto) : 0);
        return result;
    }
}
